package com.shushan.pages.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.home.bean.AppDialogBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: VipBean
 * @Desciption: //TODO
 * @author: yichaohua
 * @date: 2018-08-15
 */
public class VipBean extends NetBaseBean {

    public int first;//1首次 0 非首次
    public int vip;
    public int last_time;
    public int tb_vip = 0;
    public int tb_vip_time;
    public int sz_vip = 0;
    public int sz_vip_time;
    public int ks_vip = 0;
    public int ks_vip_time;
    public int ky_vip = 0;
    public int ky_vip_time;
    public int dc_vip = 0;
    public int dc_vip_time;
    public int tl_vip = 0;
    public int tl_vip_time;
    public String child_name;
    private List<OpenVipBean> openVipBeanList = new ArrayList<OpenVipBean>();
    private List<AppDialogBean> appDialogBeanList = new ArrayList<AppDialogBean>();
    private List<ActivityVipBean> activityBeanList = new ArrayList<ActivityVipBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        first = jsonObject.optInt("first",0);
        JSONArray jsonArray = jsonObject.optJSONArray("data");
        if(jsonArray != null){
            for (int i = 0;i < jsonArray.length();i++){
                JSONObject object = jsonArray.optJSONObject(i);
                OpenVipBean openVipBean = new OpenVipBean();
                openVipBean.initByJson(object);
                openVipBeanList.add(openVipBean);
            }
        }

        JSONArray activityArray = jsonObject.optJSONArray("activity");
        if(activityArray != null){
            for (int i = 0;i < activityArray.length();i++){
                JSONObject object = activityArray.optJSONObject(i);
                ActivityVipBean activityVipBean = new ActivityVipBean();
                activityVipBean.initByJson(object);
                activityBeanList.add(activityVipBean);
            }
        }

        JSONArray bannerArray = jsonObject.optJSONArray("banner");
        if(bannerArray != null){
            for (int i = 0;i < bannerArray.length();i++){
                JSONObject object = bannerArray.optJSONObject(i);
                AppDialogBean appDialogBean = new AppDialogBean();
                appDialogBean.initByJson(object);
                appDialogBeanList.add(appDialogBean);
            }
        }

        JSONObject useJson = jsonObject.optJSONObject("user_info");
        if(useJson != null){
            vip = useJson.optInt("vip",0);
            last_time = useJson.optInt("last_time",0);
            child_name = useJson.optString("child_name","");

            JSONArray classJsonArray = useJson.optJSONArray("classificationvip");
            if(classJsonArray != null){
                JSONObject object = classJsonArray.optJSONObject(0);
                tb_vip = object.optInt("tb_vip",0);
                tb_vip_time = object.optInt("vip_time",0);

                object = classJsonArray.optJSONObject(1);
                sz_vip = object.optInt("sz_vip",0);
                sz_vip_time = object.optInt("vip_time",0);

                object = classJsonArray.optJSONObject(2);
                ks_vip = object.optInt("ks_vip",0);
                ks_vip_time = object.optInt("vip_time",0);

                object = classJsonArray.optJSONObject(3);
                ky_vip = object.optInt("ky_vip",0);
                ky_vip_time = object.optInt("vip_time",0);

                object = classJsonArray.optJSONObject(4);
                dc_vip = object.optInt("dc_vip",0);
                dc_vip_time = object.optInt("vip_time",0);

                object = classJsonArray.optJSONObject(5);
                tl_vip = object.optInt("tl_vip",0);
                tl_vip_time = object.optInt("vip_time",0);
            }
        }
    }

    public List<OpenVipBean> getOpenVipBeanList() {
        return openVipBeanList;
    }

    public void setOpenVipBeanList(List<OpenVipBean> openVipBeanList) {
        this.openVipBeanList = openVipBeanList;
    }

    public List<AppDialogBean> getAppDialogBeanList() {
        return appDialogBeanList;
    }

    public void setAppDialogBeanList(List<AppDialogBean> appDialogBeanList) {
        this.appDialogBeanList = appDialogBeanList;
    }

    public List<ActivityVipBean> getActivityBeanList() {
        return activityBeanList;
    }

    public void setActivityBeanList(List<ActivityVipBean> activityBeanList) {
        this.activityBeanList = activityBeanList;
    }
}
